/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package doa;

import conf.HibernateUtil;
import org.hibernate.Session;

/**
 *
 * @author Misja
 */
public class HibernateSessionController{
    
    private Session hibernateSession;
    private static HibernateSessionController hibernateSessionController;
    
    public void initSession() {
        if (hibernateSession == null || HibernateUtil.getSessionFactory().isClosed()) {
            hibernateSession = HibernateUtil.getSessionFactory().openSession();
        }
    }

    public Session getHibernateSession() {
        return hibernateSession;
    }

    public void setHibernateSession(Session hibernateSession) {
        this.hibernateSession = hibernateSession;
    }
    
    public static HibernateSessionController Instance() {
        if (hibernateSessionController == null) {
            hibernateSessionController = new HibernateSessionController();
        }
        return hibernateSessionController;
    }
}
